package com.pan.hisystem.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.pan.hisystem.pojo.Drug;
import com.pan.hisystem.pojo.Prescription;
import com.pan.hisystem.pojo.PrescriptionDrugs;
import com.pan.hisystem.pojo.RespBean;
import com.pan.hisystem.service.IDrugService;
import com.pan.hisystem.service.IPrescriptionDrugsService;
import com.pan.hisystem.service.IPrescriptionService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Description 药房取药
 * @Author qingyang
 * @Date 2022/3/30 18:07
 * @Version 1.0
 **/
@RestController
@RequestMapping("/dispensary")
public class DispensaryController {

    @Autowired
    private IDrugService drugService;
    @Autowired
    private IPrescriptionDrugsService prescriptionDrugsService;
    @Autowired
    private IPrescriptionService prescriptionService;

    /*@ApiOperation(value = "获取药品")
    @GetMapping("/getDrugs")
    public List<Drug> getDrugs(){
        return drugService.list();
    }*/

    @ApiOperation(value = "完成取药")
    @PutMapping("/updateDrugs")
    public RespBean updateDrugs(Integer[] ids){
        if(ids.length==0){
            return RespBean.error("药品不能为空!");
        }
        return drugService.updateDrugs(ids);
    }

    @ApiOperation(value = "根据处方获取药品")
    @GetMapping("/getDrugsByPreId")
    public RespBean getDrugsByPreId(Integer preId){
       return prescriptionService.getDrugs(preId);
    }

    @ApiOperation(value = "根据卡号获取处方")
    @GetMapping("/getPreByMid")
    public RespBean getPreByMid(String mid){
        return prescriptionService.getPreByMid(mid);
    }

}
